package com.hm.main;

import com.hm.bean.ColumnInfo;
import com.hm.bean.ColumnNameEnum;
import com.hm.bean.DataDirectory;
import com.hm.service.DataDirectoryService;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.LinkedHashMap;

public class DataDirectoryGenerateMain {
    public static void main(String[] args){
        AbstractApplicationContext context =
                new ClassPathXmlApplicationContext("applicationContext.xml");
        DataDirectoryService service = context.getBean(DataDirectoryService.class);

        DataDirectory dataDirectory = new DataDirectory();
        //存储的地方
        dataDirectory.setBaseFielPath("F:\\");
        //
        dataDirectory.setDatabaseName("wnxg");
        System.out.println("存储路径："+dataDirectory.getBaseFielPath());
        System.out.println("数据库："+dataDirectory.getDatabaseName()+" 数据库字典生成！");
        LinkedHashMap<ColumnNameEnum, ColumnInfo> columnInfoMap = new LinkedHashMap<ColumnNameEnum, ColumnInfo>();
        columnInfoMap.put(ColumnNameEnum.COLUMN_NAME, new ColumnInfo("字段名", 15));
        columnInfoMap.put(ColumnNameEnum.COLUMN_TYPE, new ColumnInfo("数据类型", 15));
        columnInfoMap.put(ColumnNameEnum.IS_NULLABLE, new ColumnInfo("允许为空", 15));
        columnInfoMap.put(ColumnNameEnum.COLUMN_COMMENT, new ColumnInfo("字段说明", 15));
        columnInfoMap.put(ColumnNameEnum.COLUMN_DEFAULT, new ColumnInfo("默认值", 15));
        columnInfoMap.put(ColumnNameEnum.COLUMN_KEY, new ColumnInfo("键值", 15));
        dataDirectory.setTableHeader(columnInfoMap);

        service.generateDataDirectory(dataDirectory);
    }
}